GCC Rust Monthly Report #18 June 2022

Thanks again to Open Source Security, inc and Embecosm for their ongoing support for this project.

Milestone Progress

This month saw a little bit of a change of pace for the compiler – Major events happened, such as Embedded World 2022, which took a whole week. Philip and Arthur also both took a vacation, which slowed things down. Finally, a few weeks were also dedicated to making our testing dashboard, which allows you to easily see our progress. Nonetheless, we progressed a lot on const generics and are slowly but surely adding them to every phase of the compiler.

Furthermore, our GSoC students have also made very good progress – Faisal is porting more and more functions from the C++ frontend to our frontend, which will soon allow us to plug our const generics into this evaluator. This will enable our compiler to handle some basic constant folding cases. On the other hand, Andrew is improving our HIR dumps very quickly – this will improve the development experience considerably. Both students are making really good progress and are a pleasure to work with. Thank you!

We have started looking at our future upstreaming possibilities and have asked the GCC community for their input. You can follow the thread of discussion here. Feel free to join our next call to discuss it!

Finally, as pointed out last month, the video of our talk at the Live Embedded Event #3 has been released.

Monthly Community Call

Our monthly community call happened last friday. You can find the call’s agenda at the following link. We have also started hosting weekly sync-up calls for people in non-european timezones. These calls happen every week on wednesday. Join our Zulip for more information and to set a time that works for you too!

Completed Activities

gccrs

  • HIR: fixup MatchArm assignment operator PR1352
  • Ensure we support generic arguments on mangled type-paths PR1343
  • Refactor name-resolution pass PR1342
  • ci: Temporarily disable Remark CI PR1341
  • Add line! macro PR1339
  • gccrs const folding port: continue porting potential_constant_expression_1() PR1338
  • Actually set TYPE_PACKED for type_record PR1337
  • Resolve const generic parameters PR1336
  • cli: add “hir-pretty” as a “dump” option PR1335
  • hir/add: pretty printing visitor skeleton PR1332
  • Fix remaining misuses of format specifiers on 32-bit targets PR1331
  • Add location to HIR::Type base class and improve privacy error reporting PR1330
  • gccrs const folding port: start porting potential_constant_expression… PR1329
  • Lower const generics structures PR1327
  • ast: Add location to ConstGenericArg PR1326
  • Add const generic disambiguation PR1325
  • Fixes #1263; diagnostics/feature/wrapper PR1322
  • AST for const generic arguments/const application PR1317
  • Add const generic declaration to AST PR1316
  • Add base for parsing const generic application PR1315
  • Parse const generics properly PR1313
  • Refactor generic parameter parsing and report order errors PR1312
  • Fix lexing of empty comments continuing till next line PR1309
  • Fix formatting error on 32-bits targets PR1308
  • Handle super and crate in path resolution PR1307
  • docker: Fix GCCRS_BUILD info PR1300
  • rust/lex: skip broken string expression PR1299
  • rust/intrinsic: add a basic size check for transmute PR1298
  • Ast dump trait impl PR1296
  • AST Dump impl traits PR1295
  • Add new mappings for items within a module PR1294
  • Fixup name canonicalization for impl blocks PR1293
  • Add name resolution to for loops PR1292
  • Fix bad impl item overlap check PR1291
  • Reformat copyright header in rust-parse-impl.h PR1290
  • docker: Add commit information to Docker image PR1288
  • Add AST dump visitor PR1287
  • Marklive: support arrayindex PR1284
  • Add mirror branch for gccrs on https://gcc.gnu.org/git/ Issue #143
  • Add new rust component and new version rust/master to GCC Bugzilla: Bug List

Testing Dashboard

This month, we have worked hard on a way for everyone to easily see our compiler’s progress on various testsuites. You can now deploy and see locally our “testing dashboard”, which is made of a backend and a frontend entirely written in Rust, and whose purpose is to graph the amount of test passes and failures on various testsuites ran nightly. These testsuites include a parsing testsuite from the rustc testsuite, our modified version of BLAKE3 and of the 1.49 version of libcore, as well as some “successes only” testsuites from the main rust repository. We plan on deploying the webapp soon, with only a few issues remaining, for everyone to access easily from their browsers. Contributions welcome! We are compiler engineers, not web developers, and the app is currently looking a little bare 🙂

  • cache: Use proper logging PR22
  • dashboard: Remove useless function_component PR21
  • readme: Add instructions PR16
  • Make API calls in dashboard and draw graphs PR13
  • Base for REST API PR10
  • Update jsons on a schedule PR9
  • cache: Add authentication through personal GH token PR7

Contributors this month

Overall Task Status

CategoryLast MonthThis MonthDelta
TODO145152+7
In Progress2728+1
Completed389405+16
GitHub Issues

Test Cases

CategoryLast MonthThis MonthDelta
Passing63116395+84
Failed
XFAIL2331+8
XPASS
make check-rust

Bugs

CategoryLast MonthThis MonthDelta
TODO5457+3
In Progress1211-1
Completed164169+5
GitHub Bugs

Milestones Progress

Please note that we are moving slightly away from the “milestone model” as our work is starting to focus more and more on compiling our goal testcases, such as Blake3 or libcore-1.49. As such, we are working on “multiple milestones at once” and not necessarily filling out the proper labels or information. Furthermore, our students’ project milestones are undergoing quite a bit of churn and growing rapidly, so their numbers are not added as they would be misleading.

MilestoneLast MonthThis MonthDeltaStart DateCompletion DateTarget
Data Structures 1 – Core100%100%30th Nov 202027th Jan 202129th Jan 2021
Control Flow 1 – Core100%100%28th Jan 202110th Feb 202126th Feb 2021
Data Structures 2 – Generics100%100%11th Feb 202114th May 202128th May 2021
Data Structures 3 – Traits100%100%20th May 202117th Sept 202127th Aug 2021
Control Flow 2 – Pattern Matching100%%10020th Sept 20219th Dec 202129th Nov 2021
Macros and cfg expansion100%100%1st Dec 202131st Mar 202228th Mar 2022
Imports and Visibility48%97%+49%29th Mar 202227th May 2022
Const Generics0%30%+30%30th May 202225th Jul 2022
Intrinsics0%0%6th Sept 202230th Sept 2022
GitHub Milestones

Risks

RiskImpact (1-3)Likelihood (0-10)Risk (I * L)Mitigation
Rust Language Changes3721Keep up to date with the Rust language on a regular basis
Going over target dates3515Maintain status reports and issue tracking to stakeholders

Cross testing project

The amount of tests was reduced between last month and this month – This is due to us setting up a nightly run of these testsuites and fixing a version of our rust submodule. This explains why, despite the number of successes falling, the success percentage is going up in some cases.

The format is as follows: <test cases> - <passes> - <failures>

TestsuiteCompilerLast monthThis monthSuccess delta (%)
rustc testsuitegccrs -fsyntax-only15481 – 12783 – 269813337 – 11217 – 2120-1566 (+1.5%)
gccrs testsuiterustc stable563 – 390 – 173607 – 408 – 199-18 (-2.1%)
rustc testsuite passing testsgccrs6603 – 877 – 57265783 – 740 – 5043-137 (-0.5%)
rustc testsuite (no_std)gccrs2764 – 698 – 20662179 – 616 – 1563-82 (-11.3%)
rustc testsuite (no_core)gccrs178 – 145 – 336 – 5 – 1-33 (+1.9%)
blake3gccrs4 – 1 – 3
libcore-1.49gccrs1 – 0 – 1

System Integration Tests

Planned Activities

  • Metadata exports
  • Finish adding const generics to the compiler pipeline
  • Work on overflow traps

Detailed changelog

super and crate path handling

Our name resolution and module handling components could previously not resolve complex relative paths such as crate::foo::bar or super::super::super::foo. This is now fixed by adding proper module tree handling and improving our path resolution pass.

mod a {
    pub fn foo() {}
}

mod b {
    pub fn foo() {
        // go UP in the hierarchy, then DOWN and DOWN
        super::a::foo();
    }
}

mod foo {
    pub struct bar(pub i32);
}

             // Go to the root of the module tree, then DOWN and DOWN
fn test() -> crate::foo::bar {
    foo::bar(123)
}

Const generics parsing

As pointed out earlier, our parser did not support const generic declaration or application up until this week. We added the necessary features and took the time to refactor some parts of the parser, which made for nice little improvements all around.

Here are a few snippets from our testsuite:

// There are errors about unused generic parameters, but we can't handle that yet.
// Still, this code is invalid Rust.

mod sain {
    struct Foo<const N: usize>;
    struct Bar<T, const N: usize>;
    struct Baz<'l, T, const N: usize>;
}

mod doux {
    struct Foo<const N: usize = 15>;
    struct Bar<T, const N: usize = { 14 * 2 }>;

    const N_DEFAULT: usize = 3;

    struct Baz<'l, T, const N: usize = N_DEFAULT>;
}
struct Foo<const N>; // { dg-error "expecting .:. but .>. found" }
struct Bar<const N: >; // { dg-error "unrecognised token .>. in type" } struct Baz<const N: usize = >; // { dg-error "invalid token for start of default value for const generic parameter" }
const M: usize = 4;

struct Foo<T, const N: usize = 1> {
    value: [i32; N],
}

fn main() {
    let foo = Foo::<i32> { value: [15] };
    let foo = Foo::<i32, 2> { value: [15, 13] };
    let foo: Foo<i32, M> = Foo::<i32, 4> {
        value: [15, 13, 11, 9],
    };

    let invalid_foo: Foo<i32, { 1 + 1 }> = Foo::<i32, 3> { value: [15, 13] };
    let invalid_foo: Foo<i32, { 1 + 1 }> = Foo::<i32, M> { value: [15, 13] };
    let invalid_foo: Foo<i32> = Foo::<i32, 2> { value: [15, 13] };
}

Please note that const expressions are not yet handled in later parts of the compiler, hence the lack of typechecking errors.

Dashboard

You can access the dashboard’s repository here! Since we are not web developers, we probably made a bit of a mess, and all contributions are welcome! Furthermore, things like styling are currently absent from the repository as we did not want to embarass ourselves.

The entirety of the dashboard is written in Rust, backend and frontend. It was a really pleasant experience and a joy to work with.

You can run the dashboard locally quite easily, but it will be deployed publicly soon.

Backend

The backend exposes a REST API thanks to the rocket framework.

Our testing project is set-up to run all testsuites nightly and then upload the results as artifacts. Thanks to the octocrab crate, we perform daily requests to the GitHub API and cache these results.

We then serve them on three different endpoints (for now!):

  1. api/testsuites, which returns a list of all available keys
  2. api/testsuites/<key> to get the list of runs for that specific key
  3. api/testsuites/<key>/<date> for the result of that specific nightly run

Frontend

The frontend is a simple combination of Yew and plotters. We perform calls to the API to get a list of testsuites to display, and then fetch each of their results accordingly and graph them. The interface and styling are very basic, and we hope to add more functionality later on – zooming on a specific date range, hovering on points to get the exact data, etc.

Leave a Reply

Your email address will not be published.